// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from "vue";
import * as gsap from "gsap";
import app from "@/assets/js/app";
import router from "./router";
import "./assets/js/app/utils/sys-utils/directive";
import * as echarts from "echarts";
import store from "./store";
import "@/assets/css/index.scss";
import VueI18n from "vue-i18n";
import Result from "./assets/js/app/cmlpanel/components/ai/voiceRecognize/result.js"; //语音识别结果组件
import App from "./assets/js/app/baseComponents/anovApp";
import xhr from "./api/restful/api.js";
import platformXhr from "./assets/js/app/platform_restful/api.js";
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import { DrawSVGPlugin, CustomEase, ScrambleTextPlugin, SplitText } from "dtc";
import "./components/index"; //引入全局组件
//import './mixins/extemal' //混入全局mixins
import "./mixins/getList";
import "./mixins/formatEchartsData"; //混入全局echarts格式整理
Vue.use(ElementUI);
Vue.use(app.plugins);
Vue.use(app.cmlpanel, store);
Vue.use(VueI18n);

//内部组件库
import diUI from "@vis/di-ui";
Vue.use(diUI);

Vue.prototype.$result = Result;
Vue.prototype.$echarts = echarts;
Vue.prototype.$xhr = xhr;
Vue.prototype.$platformXhr = platformXhr;
import "/src/components/index"; // 引入全局组件
//注册动画插件
DrawSVGPlugin();
CustomEase();
ScrambleTextPlugin();
SplitText();
Vue.directive("tableScroll", {
  bind(el, binding) {
    // el-table 内容滚动区域
    const bodyWrap = el.querySelector(".el-table__body-wrapper");
    bodyWrap.addEventListener("scroll", function () {
      let sign = 70;
      // 滚动到底部
      const scrollDistance =
        this.scrollHeight - this.scrollTop - this.clientHeight;
      // console.log(scrollDistance);
      // console.log('scroll pos:' + this.scrollHeight + '-'
      // + this.scrollTop + '-' + this.clientHeight + '-' + scrollDistance)
      if (scrollDistance <= sign) {
        binding.value();
      }
    });
  },
});
// 国际化
const i18n = new VueI18n({
  locale: "zh-CN",
  messages: {
    "zh-CN": require("./assets/i18n/zh-CN.json"),
    "en-US": require("./assets/i18n/en-US.json"),
  },
});
// 额外设置配置项
app.$on(app.EventType.configInit, () => {
  // let config = {
  // autoInit: false,
  // env: { designSize: { w: 1920, h: 1080 } },
  //   pages: [
  //     {
  //       path: '/firstPage',
  //       parts: [
  //         //  左上
  //         {
  //           id: 'leftCenterTop',
  //           style: {
  //             width: '422px',
  //             height: '610px',
  //             top: '127px',
  //             left: '3165px'
  //           }
  //         }
  //       ]
  //     }
  //   ],
  //   destroyParts: [
  //     {
  //       '/firstPage_leftTop': {
  //         id: 'leftTop',
  //         style: {
  //           height: '38px',
  //           left: '25px',
  //           top: '81px',
  //           width: '431px'
  //         }
  //       }
  //     }
  //   ]
  // }
  let config = {};
  app.setServerConfig(config);
});

import { Message } from "element-ui";

Vue.prototype.$message = Message;

//可视化平台初始化
window.app = app;
app.root = new Vue({
  router,
  store,
  i18n,
  render: (h) => h(App),
}).$mount("#app");
